package com.jiang.action;

import org.apache.commons.lang.StringUtils;

import com.jiang.vo.News;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class ValidateAction extends ActionSupport {

	private News news;

	public News getNews() {
		return news;
	}

	public void setNews(News news) {
		this.news = news;
	}

	@Override
	public void validate() {
		System.out.println("运行数据验证的方法!");
		if(news.getNid()== null){
			super.addFieldError("news.nid", super.getText("news.null.msg", new String[]{"新闻编号"}));
		}
		if(StringUtils.isBlank(news.getTitle())){
			super.addFieldError("news.title", super.getText("news.null.msg", new String[]{"新闻标题"}));
		}
		if(news.getPrice()==null){
			super.addFieldError("news.price", super.getText("news.null.msg", new String[]{"新闻价值"}));
		}
		if(news.getPubdate()==null){
			super.addFieldError("news.pubdate", super.getText("news.null.msg", new String[]{"发布日期"}));
		}
	}

	public String add() {

		System.out.println("执行增加的方法!");

		return NONE;
	}

}
